<template>
	<view>
		<view class="main">
	<!-- <view class="shuru t1">商户微信支付id</view> -->
			<view class="shuru" v-show="wx">
				<text class="shuru_tit t1">商户微信支付id</text>
				<input type="text" class="shuru_text t1" value="" v-model="wids" placeholder="请输入商户微信支付id" />
			</view>
			<view class="shuru" v-show="zfb">
				<text class="shuru_tit t1">商户支付宝支付id</text>
				<input type="text" class="shuru_text t1" value="" v-model="zids" placeholder="请输入商户支付宝支付id" />
			</view>
		</view>
		<view class="tuic t2" @click="info()">确定</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: '',
				imageSrc: '',
				src: '',
				wids: '',
				zids: '',
				index: 0,
				wx:false,
				zfb:false,
				sid:'',
			}
		},
		onLoad(option) {
			this.imageSrc = '';

			var _this = this;
			
			if(option.t){
					_this.sid=option.sid;
				if(option.t==1){
				uni.setNavigationBarTitle({
					title: "绑定商户微信支付id"
				});
					_this.wx=true;
				}else{
				uni.setNavigationBarTitle({
					title: "绑定商户支付宝支付id"
				});
					_this.zfb=true;
				}
			}
			
			uni.getStorage({
				key: 'user',
				success: function(res) {
					_this.mainid = res.data.id;
					
				}
			});
		},
		methods: {	
			info() {
				var _this = this;
				// console.log(_this.qbid);
				if (_this.checks === false) {
					return false
				}
				if (!_this.phone) {

					uni.showToast({
						title: '请输入代理手机号',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				_this.checks = false
				var _this = this;
				var data = {
					"aliId":  _this.zids,
					"invitePhone":'',
					"mchId": _this.sid,
					"mchPhone": "",
					"wechatId": _this.wids
				}
				data = JSON.stringify(data);
				uni.request({
					header: {
						'Content-Type': 'application/json', //自定义请求头信息
					},
					url: getApp().globalData.url + 'v1/mch/bindInvite', //仅为示例，并非真实接口地址。
					method: 'post',
					data: data,
					success: (res) => {
				_this.checks = true;
						if (res.data.status == '200') {
							uni.showToast({
								title: '商户支付id提交成功,等待审核',
								icon: 'none',
								duration: 2000
							});
							setTimeout(function() {
								uni.navigateBack({
									delta: 1
								})
							}, 2000)

						} else {

							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					},
					fail: (error) => {
				_this.checks = true;
						console.log(error)
					}
				});
			},
		}
	}
</script>

<style>
	.shuru {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		border-radius: 1vw;
		overflow: hidden;
		padding: 2vw 4vw;
		background: #fff;
		margin-top: 3vw;
		box-shadow: 0px 0px 5px #eee;
	}

	.shuru_tit {
		width: 100%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: left;
	}

	.shuru_text {
		width: 100%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: left;
		text-align: left;
	}

	.shuru_image {
		width: 10vw;
		height: 10vw;
		display: block;
		float: right;
		border-radius: 2vw;
		overflow: hidden;
		background: #F2F2F2;
	}

	/* 	.tuic {
		width: 90%;
		height: 14vw;
		display: block;
		float: left;
		text-align: center;
		line-height: 14vw;
		background: url(../../static/img/tuichu.png) no-repeat top center;
		background-size: 100%;
		margin: 0 5%;
		margin-top: 3vw;
	} */
</style>
